#ifndef _MAINFORM_H_
#define _MAINFORM_H_

#include <FBase.h>
#include <FUi.h>
#include <FMedia.h>
#include <FSystem.h>
#include <FApp.h>
#include <FGrpBitmap.h>


class MainForm: public Osp::Ui::Controls::Form,
		public Osp::Media::IVideoRecorderEventListener,
		public Osp::Media::ICameraEventListener,
		public Osp::Ui::IActionEventListener
{

	// Construction
public:
	MainForm(void);
	virtual ~MainForm(void);
	bool Initialize(void);
	virtual void
	OnActionPerformed(const Osp::Ui::Control &source, int actionId);
	// Implementation
public:
	Osp::Media::Camera *__pCamera;
	Osp::Media::VideoRecorder *__pVideoRecorder;
	Osp::Ui::Controls::MessageBox *__pMessageBox;
	Osp::Ui::Controls::Button *__pButton;
	Osp::Graphics::Color __onColor;
	Osp::Graphics::Color __offColor;
	static const int __maxBufferFileSize = 1024 * 20; //in KB
	static const int __minBufferFileSize = 1024 * 2; //in KB
	long __bufferFileSize; //in KB
	Osp::Base::String __bufferFile;
	bool firstRunCheckOK;

public:
	virtual result OnInitializing(void);
	virtual result OnTerminating(void);

	virtual void OnVideoRecorderCanceled(result r)
	{
	}
	virtual void OnVideoRecorderClosed(result r)
	{
		AppLog("OnVideoRecorderClosed");
	}
	virtual void OnVideoRecorderEndReached(
			Osp::Media::RecordingEndCondition endCondition);
	virtual void
	OnVideoRecorderErrorOccurred(Osp::Media::RecorderErrorReason r);
	virtual void OnVideoRecorderPaused(result r)
	{
	}
	virtual void OnVideoRecorderStarted(result r)
	{
		AppLog("OnVideoRecorderStarted");
	}
	virtual void OnVideoRecorderStopped(result r)
	{
		AppLog("OnVideoRecorderStopped");
	}

	virtual void OnCameraAutoFocused(bool completeCondition)
	{
	}
	virtual void OnCameraCaptured(Osp::Base::ByteBuffer &capturedData, result r)
	{
	}
	virtual void OnCameraErrorOccurred(Osp::Media::CameraErrorReason err);
	virtual void OnCameraPreviewed(Osp::Base::ByteBuffer &previewedData,
			result r)
	{
	}
public:
	result setupCamera();
	result setupRecorder();
	result startRecorder();
	result showMessageBox(Osp::Base::String str, bool isModel = true);
	result firstRunCheck();
	Osp::Base::String GetString(Osp::Base::String id);
	void Terminate();
};

#endif	//_MAINFORM_H_
